const state = {
    sidebar: {
        isCollapse: false, // false开启侧边栏状态
        closeCollapse: false, // false打开侧边栏， true关闭侧边栏
        drawerOpen: false, // false关闭抽屉， true打开抽屉
        width: window.innerWidth || undefined // 当前宽度
    }
}

const mutations = {
    // 设置侧边栏状态
    setCollapse(state, payload = undefined) {
        // 当payload不等于undefined 时，payload为true或false，否则!state.sidebar.isCollapse
        state.sidebar.isCollapse = payload !== undefined ? payload : !state.sidebar.isCollapse
    },
    // 设置是否关闭侧边栏
    setCloseCollapse(state, payload) {
        state.sidebar.closeCollapse = payload
    },
    // 设置抽屉状态
    setDrawerOpen(state, payload = undefined) {
        // 当payload不等于undefined 时，payload为true或false，否则!state.sidebar.drawerOpen
        state.sidebar.drawerOpen = payload !== undefined ? payload : !state.sidebar.drawerOpen
    },
    // 存储当前宽度
    setWidth(state, payload) {
        state.sidebar.width = payload
    }
}

const actions = {

}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
